[Backend] Implement Winston Request/Response Logger#322
Open
armorbreak001 wants to merge 1 commit intoGalactiGuild:mainfrom
Open
[Backend] Implement Winston Request/Response Logger#322armorbreak001 wants to merge 1 commit intoGalactiGuild:mainfrom
armorbreak001 wants to merge 1 commit intoGalactiGuild:mainfrom
Conversation
- Add LoggerMiddleware intercepting all HTTP requests - Logs: [Method] [URL] [IP] [StatusCode] [DurationMs] - Redacts sensitive fields: password, token, apiKey, secret, etc. - Respects X-Forwarded-For for reverse proxy deployments - Uses WinstonLogger with level based on status code (error/warn/info) - Logs request body (redacted) for non-GET requests - Includes content-length and user-agent in log output - Applied globally via NestModule.configure() for all routes
2b16b70 to
f784d23
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #277
What was done
winston.logger.ts:/logs/directory)winston-daily-rotate-file—application-YYYY-MM-DD.loganderror-YYYY-MM-DD.loglogger.middleware.ts:[METHOD] [URL] - [IP] - [StatusCode] - [Elapsed MS]errorfor 5xx,warnfor 4xx,infofor successLoggerModule: Now implementsNestModule, applies middleware globally viaconfigure()winston-daily-rotate-filedependencyHow to verify
cd backend && npm install(to install winston-daily-rotate-file)npm run start:dev2026-04-14 19:30:00 info: GET /health - localhost - 200 - 5msNODE_ENV=productionand restart — logs will write tologs/application-YYYY-MM-DD.logandlogs/error-YYYY-MM-DD.log{"password": "secret", "token": "abc"}— verify it logs as{"password": "[REDACTED]", "token": "[REDACTED]"}